#pragma once

#include <osg/Vec3>
#include <osg/Matrix>
#include "actorbase.h"
#include "datatypedefine.h"
#include "vrdatacore_global.h"
#include <osg\StateSet>

namespace VrDataCore
{
	class Map;

	class VRDATACORE_EXPORT TransformableActor : public CoreBase::ActorBase
	{
	public:
		enum StateSetType
		{
			DEFAULT_STATESET,
			NODEFAULT_STATESET,
			SPECIAL_STATESET,
		};
		TransformableActor();
		virtual void onMapLoadBegin(CoreBase::Map*){}
		virtual void onMapLoadEnd(CoreBase::Map*){}
		virtual void buildPropertyMap();
		virtual CoreBase::ActorFactory* getActorFactory();
		void setRotation(osg::Vec3 rotation);
		void setRotationFromMatrix(const osg::Matrix &rotation);
		osg::Vec3 getRotation();
		void setTranslation(osg::Vec3 translation);
		osg::Vec3 getTranslation();
		virtual void onRotation(const osg::Vec3 &oldvalue, const osg::Vec3 &newvalue) { }
		virtual void onTranslation(const osg::Vec3 &oldvalue, const osg::Vec3 &newvalue) { }
		virtual void addChild(CoreBase::ActorBase* mactor);
		virtual void removeChild(CoreBase::ActorBase* mactor);
		//void SetRenderCollisionGeometry(bool enable);
		//bool GetRenderCollisionGeometry() const;
		//void SetCollisionType(dtCore::CoreBase::Transformable::CollisionGeomType &type);
		//dtCore::CoreBase::Transformable::CollisionGeomType &GetCollisionType();
		//void SetCollisionRadius(float radius);
		//float GetCollisionRadius() const;
		//void SetCollisionBoxDims(const osg::Vec3 &dims);
		//osg::Vec3 GetCollisionBoxDims() const;
		//void SetCollisionLength(float length);
		//float GetCollisionLength() const;
		void setUseDefaultStateSet(bool def);
		void setUseSpecialStateSet(const QString& tag,bool enable = true);
		void setDefaultStateSet(osg::StateSet* ss);
		void useStateSet(bool use = true);
		virtual void setTraverseMask(int mask);
		int getTrasverseMask();
		void setScale(osg::Vec3 scale);
		osg::Vec3 getScale();
		virtual void setToDefaultStateSet();
	protected:
		virtual ~TransformableActor() {}
		virtual void createDrawable() = 0;
		//void SetBoxCollision();
		//void SetSphereCollision();
		//void SetCylinderCollision();
		//void SetRayCollision();
		//void SetMeshCollision();
		osg::ref_ptr<osg::StateSet>			_notDefaultStateSet;
		osg::StateSet*						_defaultPublicStateSet;
		osg::StateSet*						_specialPublicStateSet;
		StateSetType						_currentStateSet;
		StateSetType						_previousStateSet;
		//osg::Vec3							_scale;
		//float mCollisionRadius;
		//float mCollisionLength;
		//dtCore::CoreBase::Transformable::CollisionGeomType *mCollisionType;
	};
}